import React from 'react';
import { useTreadstone } from 'treadstone-components';

import { useModel } from '@umijs/max';

const BasicLayout: React.FC<{ children: React.ReactNode }> = ({ children }) => {
  const { setCurrentUser } = useTreadstone();
  const { initialState } = useModel('@@initialState');

  React.useEffect(() => {
    if (initialState?.currentUser) {
      setCurrentUser?.(initialState.currentUser);
    }
  }, [initialState?.currentUser]);

  return <>{children}</>;
};

export default BasicLayout;
